//
//  ActivityDetailController.m
//  NewPro
//
//  Created by 何荧红 on 2018/10/30.
//  Copyright © 2018 何荧红. All rights reserved.
//

#import "ActivityDetailController.h"

@interface ActivityDetailController ()
@property (nonatomic, strong) UIImageView *bgimage;

@end

@implementation ActivityDetailController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self initCSS];
}
- (void)initCSS{
    
    [self setNavBarWithTitle:@"活动详情"];
    
    self.view.backgroundColor = [UIColor colorWithHexString:@"f5f5f5"];
    
    UIScrollView *scrollView = [[UIScrollView alloc]init];
    scrollView.showsVerticalScrollIndicator = NO;
    scrollView.showsHorizontalScrollIndicator = NO;
    [self.view addSubview:scrollView];
    [scrollView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(self.view);
    }];
    self.bgimage = [[UIImageView alloc]init];
    [scrollView addSubview:self.bgimage];
    if (_imagepath) {
        if (_imagepath.length > 0) {
            UIImage *image = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:_imagepath]]];
            CGFloat height = image.size.height/image.size.width * SCREEN_WIDTH;
            [self.bgimage mas_makeConstraints:^(MASConstraintMaker *make) {
                make.top.equalTo(scrollView.mas_top);
                make.left.equalTo(scrollView.mas_left);
                make.width.mas_equalTo(SCREEN_WIDTH);
                make.height.mas_equalTo(height);
            }];
            [self.bgimage sd_setImageWithURL:[NSURL URLWithString:_imagepath]];
            if (height < SCREEN_HEIGHT - iPhoneX_Top) {
                scrollView.contentSize = CGSizeMake(SCREEN_WIDTH, SCREEN_HEIGHT - 30);
            }else{
                scrollView.contentSize = CGSizeMake(SCREEN_WIDTH, height);
            }
        }
    }
}

@end
